using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping
{
	public class PurchaseRequsitionMap : EntityTypeConfiguration<PurchaseRequsition>
	{
		public PurchaseRequsitionMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			this.Property(t => t.CodeValue)
				.HasMaxLength(30);
				
			this.Property(t => t.RequestBy)
				.HasMaxLength(50);
				
			// Table & Column Mappings
			this.ToTable("PurchaseRequsitions");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.CodeValue).HasColumnName("CodeValue");
			this.Property(t => t.ReleasedDate).HasColumnName("ReleasedDate");
			this.Property(t => t.RequestBy).HasColumnName("RequestBy");
			this.Property(t => t.Frequency).HasColumnName("Frequency");
			this.Property(t => t.NeedTime).HasColumnName("NeedTime");
			this.Property(t => t.Flag).HasColumnName("Flag");
			this.Property(t => t.DocumentStatusId).HasColumnName("DocumentStatusId");

			// Relationships
			this.HasOptional(t => t.RefDocumentStatus)
				.WithMany(t => t.PurchaseRequsitions)
				.HasForeignKey(d => d.DocumentStatusId);
				
		}
	}
}

